﻿using HCDV.HCSP;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace hcrainMvc.ashx.spfunction
{
    public static class fuc_Do
    {
        public static void fucDoIn(string funname, Hashtable infos)
        {
            if (funname == "fuc_delOldStoreOutByGroup")
            {
                fuc_delOldStoreOutByGroup(infos);
            }
            else if (funname == "fuc_delOldtask_send_infoByInfo")
            {
                fuc_delOldtask_send_infoByInfo(infos);
            }
        }
        /// <summary>
        /// 采摘发货出库登录--删除上一次记录（原因：没有分析是否要update,所以 删除再插入）
        /// </summary>
        /// <param name="infos"></param>
        private static void fuc_delOldtask_send_infoByInfo(Hashtable infos)
        {
            using (dbsimple db = new dbsimple())
            {
                db.exe("delete from task_send_info where csgetpc='" + infos["fcsgetpc"].ToString() + "'" +
                    " and setdate='" + infos["fsetdate"].ToString() + "'"
                    + " and settocenterid=" + infos["fsettocenterid"].ToString()
                    + " and productstate='" + infos["fproductstate"].ToString() + "'");
            }
            if (infos["fproductstate"].ToString() == "原料")
                BsForApi.JDOutStore.原料直接登记发货时同步基地的原料出库(infos["fcsgetpc"].ToString(), double.Parse(infos["fsljl"].ToString()));
            if (infos["fproductstate"].ToString() == "包装品")
                BsForApi.JDOutStore.成品直接登记发货时同步基地的原料出库(infos["fcsgetpc"].ToString(), double.Parse(infos["fsljl"].ToString()));

        }


        /// <summary>
        /// 采摘发货出库登录--删除上一次记录（原因：没有分析是否要update,所以 删除再插入）
        /// </summary>
        /// <param name="infos"></param>
        private static void fuc_delOldStoreOutByGroup(Hashtable infos)
        {
            using (dbsimple db = new dbsimple())
            {
                db.exe("delete from hsc_task_store_out where dataaddtime='" + infos["fdataaddtime"].ToString() + " 00:00:00'" +
                    " and csgetpc='" + infos["fcsgetpc"].ToString() + "'"
             + " and productstate='" + infos["fproductstate"].ToString() + "'"
                    + " and inouttype='" + infos["finouttype"].ToString() + "'");
            }
        }
    }
}